/*
 * What is an Effect?
 * Effects are graphical objects that do not affect gameplay, yet
 * convey important visual information to the player. Effects include
 * weapon animations and hit animations.
 * If the effect is animated, the animation must consist of images
 * of equal size which are placed from left to right in the source
 * bitmap.
 * An effect is drawn centered on the specified tile coordinates, even
 * if the effect bitmap is larger than TILE_SIZE*TILE_SIZE.
 * Effects are drawn to the screen after map tiles and players, but
 * before projectiles and map overlay decorations.
 */

#ifndef __EFFECT_H
#define __EFFECT_H

#include <allegro.h>
#include "rect.h"
#include "direction.h"

#define EFFECT_TEXTLEN 100
#define EFFECT_COOLDOWN_DAMAGE (1.5*FPS)

typedef struct {
	enum { EFFECT_BITMAP, EFFECT_STRIKE, EFFECT_DMGTEXT } type;
	
	BITMAP* source;
	
	// If EFFECT_DMGTEXT, the effect is a damage text string and uses the following:
	FONT* font;
	char string [EFFECT_TEXTLEN];
	
	int bmp_x; // pixels // ignored for text effects
	int bmp_y; // ignored for text effects
	int bmp_w; // ignored for text effects
	int bmp_h; // ignored for text effects
	coord_t where; // tile coordinates
	int offset_x; // pixel coords added to tile coords
	int offset_y;
	int cooldown;
	int frame_time;     // ignored for text effects
	int frame_cooldown; // ignored for text effects
	
	Direction dir; // only for EFFECT_STRIKE
} Effect;

void effect_update (Effect* effect);
void effect_draw_bg (Effect* effect, BITMAP* target, int xoffset, int yoffset);
void effect_draw_fg (Effect* effect, BITMAP* target, int xoffset, int yoffset);
Effect effect_make_weapon (BITMAP* sheet, Direction dir, coord_t where);
Effect effect_make_damage (FONT* font, const char* string, coord_t where);

#endif // __EFFECT_H
